package demoSet;

import demo2.Emp;

import java.util.Map;

public class TestMap {
        public void addEmp(Map<String, Emp> map, Emp emp) {
            map.put(emp.getNumber(), emp);
        }

        public void findAllEmp(Map<String, Emp> map) {
            for (Map.Entry<String, Emp> entry : map.entrySet()) {
                System.out.println(entry.getValue());
            }
        }

        public Emp findEmpName(Map<String, Emp> map, String empName) {
            for (Map.Entry<String, Emp> entry : map.entrySet()) {
                if (empName.equals(entry.getValue().getName())) {
                    return entry.getValue();
                }
            }
            return null;
        }

        public void deleteEmp(Map<String, Emp> map, String empNumber) {
            map.remove(empNumber);
        }

        public Emp findEmpNumber(Map<String, Emp> map, String empNumber) {
            return map.get(empNumber);
        }

        public void updateEmp(Map<String, Emp> map, Emp emp) {
            map.put(emp.getNumber(), emp);
        }
    }